  var id = getvl("id");

$(function(){
	  if(id!=''){
	  	zhanghuxinxi(id);
	  	//$("#duihuanjilu").attr("href","23.3.0wodejinbi_duihuan.html?id="+id);
	  	$("#yunfeishezhi").attr("href","26.1.0xiugaidianpu_yunfei.html?id="+id);
	  }else{
	  	alert("传入值有误");
	  }
});
 function  zhanghuxinxi(id){
   	$.ajax({
		url: urlcore + "/api/shopInfo/selectagno1?id="+id,
		type: "get",
		dataType: 'json',
		contentType: "application/json;charset=utf-8",
		success:function(data){
			if (data.success == true) {
			//	alert(JSON.stringify(data.data));
				   var da=data.data;
				   
				   $("#dengji").attr("href","26.2.0xiugaidianpu_xinyu.html?id="+da.id);
				   $("#idss").val(da.id);
				   	$("#jingrudianpu").attr("href","../6.0.0dianpu.html?id="+da.id);
				var dianjiatouxiang='<ul class="geren_touxiang">'+
'	        <li class="clearfix">'+
'	            <label>头像</label>'+
'	            <div class="fabu_geren">'+
'	                <div id="preview">'+
'	                    <img onerror="errorImg(this)" id="imghead" border=0 src="'+da.headImg+'" />'+
'	                </div>'+
'	       <div class="fabu_file"><input type="file" onchange="previewImage(this)" /></div>'+
'	            </div>'+
'	        </li>'+
'	    </ul>';
           $("#dianjiatouxiang").append(dianjiatouxiang);
          $("#touxiang").val(da.headImg);
               var imgs=da.storeImg;
               var imgStr1="";
               if(imgs!=null){
               	$("#preview1").html("");
              var imgarr1 = imgs.split("***");
              $.each(imgarr1,function(index,value){
              	if(index==0){
              		 	  imgStr1 +=' <img id="imghead1" border=0 src="'+value+'" />';
              		 	  $("#preview1").append(imgStr1);
              		 	  $("#fengmian").val(value);
              	}
              });
               }
            
                if(da.sortType!=null){
                	 $(".leibiefuns").text(da.sortType.sortName);
                }
                
                if(da.sortTypeId!=null && da.sortTypeId!=""){
                	 $("#leibiefuns").val(da.sortTypeId);
                }
               
                var storeLevels="";
               if(da.storeLevel==1){
               	storeLevels="普通店铺";
               }else if(da.storeLevel==2){
               	storeLevels="银牌店铺";
               }else if(da.storeLevel==3){
               	storeLevels="金牌店铺";
               }
              var  creditLevel=da.creditLevel;
                 if(creditLevel<=5){
                  	  for(var i=0;i<creditLevel;i++){
                  	  
                       var imgss='<img src="img/aixin.png"/>';
                         $('#imgss').append(imgss);
                  }
                  	//  alert()
                  	  $("#jifen").html("信誉积分"+(creditLevel*1000));
                  }else if(creditLevel<=10){
                  	var credit=creditLevel-5;
                  	  for(var i=0;i<credit;i++){
                       var imgss='<img src="img/zuan.png"/>';
                         $('#imgss').append(imgss);
                  }
                  	   $("#jifen").html("信誉积分"+(creditLevel*10000));
                  }else if(creditLevel<=15){
                  	var credit=creditLevel-10;
                  	 for(var i=0;i<credit;i++){
                       var imgss='<img src="img/guan.png"/>';
                         $('#imgss').append(imgss);
                  }
                  	   $("#jifen").html("信誉积分"+(creditLevel*1000000));
                  }
                  
                  $("#mingcheng").text(da.storeName);
                  $("#storeLevels").text(storeLevels);
                  
         var dianpuxinxis="";
      var  creditLevel=da.creditLevel;
                 if(creditLevel<=5){
                  	  for(var i=0;i<creditLevel;i++){
                       dianpuxinxis+='<img src="../images/aixin.png"/>';
                        
                  }
                  	   dianpuxinxis+='<i>信誉'+creditLevel*1000+'分</i>';
                  	
                  }else if(creditLevel<=10){
                  	var credit=creditLevel-5;
                  	  for(var i=0;i<credit;i++){
                     dianpuxinxis+='<img src="../images/zhuanshi.png"/>';
                        
                  }
                  	   dianpuxinxis+='<i>信誉'+creditLevel*10000+'分</i>';
                  }else if(creditLevel<=15){
                  	var credit=creditLevel-10;
                  	 for(var i=0;i<credit;i++){
                       dianpuxinxis+='<img src="img/guan.png"/>';
                  }
                  	   dianpuxinxis+='<i>信誉'+creditLevel*1000000+'分</i>';
                  	}
                  $("#userName").val(da.userName);
                   $('#dengji').append(dianpuxinxis);
                   
                   
                   if(da.isMix==0){
                   	$("#hunpi").val(0);
                   	 $("#hun").attr("class","mui-switch mui-switch-mini");
                   }else if(da.isMix==1){
                   	$("#hunpi").val(1);
                  $("#hun").attr("class","mui-switch mui-switch-mini mui-active");
                   }
                   
                    if(da.isChange==0){
                    	$("#baohuan").val(0);
                   	 $("#bao").attr("class","mui-switch mui-switch-mini");
                   	  $("#tishis").append('<p class="fr" style="margin-bottom: 0;" >交易中不允许买家退换货</p>');
                   }else if(da.isChange==1){
                   	$("#baohuan").val(1);
                  $("#bao").attr("class","mui-switch mui-switch-mini mui-active");
                    $("#tishis").append('<p class="fr" style="margin-bottom: 0;" >交易中允许买家退换货</p>');
                   }
                   $("#cityResult3").html(da.province+"-"+da.city+"-"+da.county);
                   $("#dangkoubianhao").val(da.addressNumber);
                   $("#tuiguang").val(da.spreadCode);
                   
      $("#iphon").val(da.phone);         
    /*  $("#weixin").val(da.wxName);      */   
     $("#dizhi").val(da.address);
     $("#qipiliang").val(da.getMin);
     $("#dabaoshu").val(da.packMin);
     $("#hunpijianshu").val(da.mixNumber);
     $("#gonggao").val(da.shopNotice);
			}
		},
		error:function() {
			/* Act on the event */
			alert("error");
		}
	});	
}

function mingxi(){
	if(id!=''){
			$.ajax({
		url: urlcore + "/api/goldRecord/selectList2?id="+id,
		type: "get",
		dataType: 'json',
		contentType: "application/json;charset=utf-8",
		success:function(data){
			if (data.success == true) {
				$.each(data.data.list, function(y,n) {
						var gmtDatetime = new Date(n.gmtDatetime).pattern("yyyy-MM-dd hh:mm:ss");
					var jingbijilu='<dd class="clearfix">'+
'				<div class="yue_list_left">'+
'					<h5>'+n.title+'</h5>'+
'					<span>'+gmtDatetime+'</span>'+
'				</div>'+
'				<div class="yue_list_right">+'+n.gold+'</div>'+
'			</dd>';
				
				$("#jingbijilu").append(jingbijilu);
				});
			}
		},
		error:function() {
			/* Act on the event */
			alert("error");
		}
	});	
	
	}else{
		alert("没有值传入");
	}
}



function baochun(){
	 var hunpi=$("#hunpi").val();
	 var baohuan=$("#baohuan").val();
	 var touxiang=$("#touxiang").val();
	 var fengmian=$("#fengmian").val();
	  var leibiefuns=$("#leibiefuns").val();
	 var iphon=$("#iphon").val();
	 var userName=$("#userName").val();
	 var dizhi=$("#dizhi").val();
   var idss=$("#idss").val();
	 	 var dabaoshu=$("#dabaoshu").val();
	 var hunpijianshu=$("#hunpijianshu").val();
	 var gonggao=$("#gonggao").val();
	 var cityResult3=$("#cityResult3").html();
	 var dangkoubianhao=$("#dangkoubianhao").val();
	 var  tuikuagn=$("#tuiguang").val();
	 if(hunpi==''){
	 	  alert("混批没填入");
	 }else if(touxiang==''){
	 	 alert("头像不能为空");
	 }else if(fengmian==''){
	 	 alert("封面不能为空");
	 }else if(userName==''){
	 	alert("用户名不能为空")
	 }else if(dizhi==''){
	 	alert("地址不能为空");
	 }else if(dabaoshu==''){
	 	  alert('打包数未填写');
	 }else if(cityResult3=="请选择"){
	 	alert("地区未填写");
	 }else{
	 var imgStr3="";
	 var imgStr4="";
	 var imgStr5="";
	    var imgarr1 =cityResult3.split("-");
	  $.each(imgarr1, function(index, value) {
							if(index==1){
								imgStr3=value;
							}else if(index==2){
								imgStr4=value;
							}else{
								imgStr5=value;
							}
						});
	    
		 $.ajax({
		url: urlcore + "/api/shopInfo/Gomodify",
		type: "post",
		contentType: "application/json;charset=utf-8",
		data: JSON.stringify({
			 "id":idss,
			 "isMix":hunpi,
			 "isChange":baohuan,
			 "headImg":touxiang,
			 "storeImg":fengmian,/*"wxName":weixin,*/
			 "phone":iphon,
			 "userName":userName,
			 "address":dizhi,
			  "packMin":dabaoshu,
			  "mixNumber":hunpijianshu,
			  "shopNotice":gonggao,
			  "province":imgStr3,
			  "city":imgStr4,
			  "county":imgStr5,
			  "addressNumber":dangkoubianhao,
			  "tuikuagn":tuiguang,
			  "sortTypeId":leibiefuns
		}),
		dataType: "json",
		success: function(data) {
			if(data.success == true) {
		   var vat=window.location.href;
		   window.location.href=vat;
		     }
		},error: function() {
			alert("error");
		}
	});
		
	}
}





	function leibiefun(id,name){
	$(".leibiefuns").html("请选择主营类别");
	$("#leibiefuns").val("");
	$(".leibiefuns").html(name);
	$("#leibiefuns").val(id);
	//$("#pfsq span").removeClass('up');  //点击关闭按钮的时候，遮罩层关闭
	        $("#bg,.payment_time_mask01").css("display", "none");
	        $(".zhiweifabu01 em").text($(this).html());
	        $(".zhiweifabu01 i").removeClass("up").addClass("down");
	    //$(".payment_time_mask04 li").on('click',function () {});
	}
	
	 function zhuyingleibies(){
       	$("#zhuyingleibie").html("");
	    $.ajax({
        url:urlcore+"/api/sortType/selectList",
			type: "get",
			dataType: 'json',
			contentType: "application/json;charset=utf-8",
			success: function(data) {
				if(data.success == true) {
				/*	$("#xialakuang").show();*/
				$.each(data.data.list,function(y,h){
					var zhuyingleibie='<li onclick="leibiefun('+h.id+',\''+h.sortName+'\')" id="'+h.id+'" >'+h.sortName+'</li>';
			    $("#zhuyingleibie").append(zhuyingleibie);
					});
				}
			},
			error: function() {
				alert("error");
			}
		});
		//批发市场弹窗
    $(function () {
	    $(".zhiweifabu01 em").click(function () {
	        $("#bg").css({
	            display: "block", height: $(document).height()
	        });
	        var $box = $('.payment_time_mask01');
	        $box.css({
	            display: "block",
	        });
	        $(".zhiweifabu01 i").addClass("up");
	    });
	});
	
	 }
	

